import Vue from "vue";
import App from "./App.vue";
import store from "@/store";
import router from "@/router";
import TypeNav from "@/components/TypeNav";
import Swiper from "@/components/Swiper";
import Pagenation from "@/components/Pagenation";
import "@/mock";
import VueLazyload from "vue-lazyload";
import loading from "@/assets/images/loading.gif";
import VeeValidate from "vee-validate";
import zh_CN from "vee-validate/dist/locale/zh_CN"; // 引入中文message

//按需引入elementUI中的某些组件
import { Button, Dialog, Message } from "element-ui";

//引入之后作为插件使用
Vue.use(Button);
Vue.use(Dialog);
Vue.use(VueLazyload, {
  loading,
});
Vue.use(VeeValidate);
//务必在使用当前插件之后再进行配置
VeeValidate.Validator.localize("zh_CN", {
  messages: {
    ...zh_CN.messages,
    is: (field) => `${field}必须与密码相同`, // 修改内置规则的message
  },
  attributes: {
    // 给校验的field属性名映射中文名称
    phone: "手机号",
    verify: "验证码",
    password: "密码",
    passwordAgain: "确认密码",
    agree:"协议"
  },
});
Vue.prototype.$message = Message;

Vue.config.productionTip = false;

//全局注册公共组件TypeNav
Vue.component("TypeNav", TypeNav);
//全局注册公共组件Swiper
Vue.component("Swiper", Swiper);
//全局注册公共组件Pagenation
Vue.component("Pagenation", Pagenation);


VeeValidate.Validator.extend("agree", {
  //参数value就是接受当前表单的值
  validate: (value) => {
    //  在函数中书写判断条件,如果条件通过则返回true 否则返回false
    /* if(value===true){
      return true
    }else{
      return false
    } */
    return value;
  },
  getMessage: (field) => field + "必须同意",
});

new Vue({
  render: (h) => h(App),
  router,
  store,
  //事件总线
  beforeCreate() {
    Vue.prototype.$bus = this;
  },
}).$mount("#app");
